<?

class bf_mime {

	private $opts;

	public function __construct($options = array()) {
		$this->opts = array_merge(array(
			'*' => 'application/octet-stream',
		), $options);
	}

	public function __destruct() {
	}

	public function set($ext, $mime_type = false) {
		if (is_array($ext) && $mime_type === false) {
			foreach ($ext as $x => $t)
				$this->set($x, $t);
		} else {
			$this->opts[$ext] = $mime_type;
		}
	}

	public function get($path) {
		$m = array();
		if (preg_match('/\.([^\.]+)$/', $path, $m)) {
			$ext = $m[1];
			return (isset($this->opts[$ext]) ? $this->opts[$ext] : $this->opts['*']);
		}
		return $this->opts['*'];
	}
}

?>